#include "Babe.h"
#include "Game.h"
#include "collide.h"

#define BABE_REST_BETWEEN_POSES_IN_MS 5000

Babe::Babe(Sprite* _ps, int _x, int _y, double _unitsPerSec, 
            double _generosity) : Character(_ps,_x,_y,_unitsPerSec),
            generosity(_generosity), mPoseStartTimeInMs(0), mPoseTimeInMs(0) 
{
    this->sObjName = "Babe";
}

void Babe::Update(Game* pGame, Uint32 prevTick, Uint32 thisTick) {
}

// returns the time that this babe can pose again (time could be in the past)
Uint32 Babe::nextPosingOpportunity() {
  if(mPoseStartTimeInMs == 0) { return 0; }
  return mPoseStartTimeInMs + mPoseTimeInMs + BABE_REST_BETWEEN_POSES_IN_MS;
}

// starts the babe posing if the babe is able
void Babe::startPosing(Uint32 _now, Uint32 _length) { 
  // only start posing if we weren't already doing that
  if(nextPosingOpportunity() <= _now) {
    mPoseStartTimeInMs = _now; 
    mPoseTimeInMs = _length; 
  }
}

// returns true if the babe is currently posing
bool Babe::isPosing(Uint32 _now) { 
  if(mPoseStartTimeInMs == 0) { return false; }
  return (mPoseStartTimeInMs + mPoseTimeInMs >= _now); 
}